const path = require("path");
const Joi = require("@hapi/joi");
const handler = require(path.join(__dirname, "../services/userService"));
const { validate } = require("../middlewares/validate");

module.exports = (router, base) => {
  router.get(`/api/${base}/a`, handler.getA);

  router.post(
    `/api/${base}/login`,
    validate({
      payload: Joi.object().keys({
        username: Joi.string().required().description("用户名"),
        password: Joi.string().required().description("用户密码"),
      }),
    }),
    handler.login
  );
};
